home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / watchkit.zip / WATCHPUP.ASM < prev    next >
Assembly Source File  |  1989-09-20  |  7KB  |  285 lines

  1.  page ,132
  2.  .model tiny
  3.  .code
  4. first:
  5. ;
  6. ; WATCHCAT copyright 1989, Joseph R. Ahlgren
  7. ;  see WATCHCAT.DOC
  8. ;
  9. ; WATCHCAT performs 5 critical functions for any RBBS system:
  10. ;  1.  Reboots system if no carrier in specified period of time
  11. ;    This catches RBBS or system failures
  12. ;  2.  Reboots system if carrier lost during critical period
  13. ;    This allows Doors to be used safely
  14. ;  3.  Reboots system if 20 rings without answering phone
  15. ;    This allows system to be restarted by phone
  16. ;  4.  Reboots system if "Hit any key to return to system" message appears
  17. ;    This restarts system on a common RBBS failure
  18. ;  5.  Drops carrier if L&R shift keys pressed simultaneously
  19. ;    This allows users to be logged off without a nasty message.
  20. ;WATCHCAT loads the TSR and disables all functions
  21. ; WATCHCAT OFF disables all functions
  22. ; WATCHCAT ON enables 1,3,4,and 5
  23. ; WATCHCAT TIMER enables 2,4,and 5
  24. ;ComPort = 03f8h  ;{COM1}
  25. ;ComPort = 02f8h  ;{COM2}
  26. ;ComPort = 03e8h  ;{COM3}
  27. ;ComPort = 02e8h  ;{COM4}
  28. ;ScreenSegment = 0b800h  ;{Color}
  29. ;ScreenSegment = 0b000h  ;{Mono}
  30. ModemStatus = 0006h
  31. ModemControl = 0004h
  32. CarrierDetect = 0080h
  33. RingIndicator = 0040h
  34. tpm = 1092 ; {ticks per minute}
  35. RingTicks = 110; {6 seconds}
  36.  org 100h
  37. start:
  38.  jmp init
  39. RingTrigger dw 0
  40. RingTimer db 0
  41. Flag db 'F' and 0fh  ;  OFF ON TIME = F O I
  42. TimerInt dd ?
  43. Minutes dw 3*60  ;{minutes of no carrier to trigger reset, modified P. Eibl}
  44. Seconds dw tpm
  45. MinReset dw 3*60 ;{ change to 2 form 8 P. Eibl}
  46. ColdBoot dd 0ffff0000h
  47. ExitTimer db 0
  48. DropTrigger db 3  ;Drop DTR on L&R shift
  49. ExitMessage db 'Hit any key to return to system'
  50. ExitMessageEnd db 0
  51. ComPort dw 02f8h  ;{COM2}
  52. ScreenSegment dw 0b000h  ;{Mono}
  53. Ident db "jOeY"
  54. Ident2 db "50c4"
  55. timer:
  56.  assume ds:nothing,es:nothing,ss:nothing
  57.  cmp cs:[Flag],'F' and 0fh
  58.  jne SystemOn
  59.  jmp cs:[TimerInt]
  60. SystemOn:
  61.  push ax
  62.  push dx
  63.  push ds
  64. ;  4.  Reboots system if "Hit any key to return to system" message appears
  65. ;    This restarts system on a common RBBS failure
  66.  dec cs:[ExitTimer]
  67.  jnz NoExitLoop
  68.  push cx
  69.  push si
  70.  push di
  71.  mov ax,cs:[ScreenSegment]
  72.  mov ds,ax
  73.  mov cx,25
  74.  xor si,si
  75. SSLoop1:
  76.  push cx
  77.  push si
  78.  mov cx,ExitMessageEnd-ExitMessage
  79.  mov di,offset ExitMessage
  80. SSLoop2:
  81.  lodsw
  82.  cmp al,cs:[di]
  83.  jne SSLoop2x
  84.  inc di
  85.  loop SSLoop2
  86.  jmp short NoCarrier
  87. SSLoop2x:
  88.  pop si
  89.  pop cx
  90.  add si,160
  91.  loop SSLoop1
  92.  pop di
  93.  pop si
  94.  pop cx
  95. NoExitLoop:
  96. ;  5.  Drops carrier if L&R shift keys pressed simultaneously
  97. ;    This allows users to be logged off without a nasty message.
  98.  xor ax,ax
  99.  mov ds,ax
  100.  assume ds:Lowmem
  101.  mov al,[ShiftStatus]
  102.  and al,0fh
  103.  cmp al,cs:[DropTrigger]
  104.  jne NoShift
  105.  mov dx,cs:[ComPort]
  106.  add dx,ModemControl
  107.  in al,dx
  108. ; or al,1
  109.  and al,0feh
  110.  out dx,al       ;drop DTR
  111. NoShift:
  112. ;  3.  Reboots system if 20 rings without answering phone
  113. ;    This allows system to be restarted by phone
  114.  mov dx,[ComPort]
  115.  add dx,ModemStatus
  116.  in al,dx
  117.  test al,RingIndicator
  118.  jz NotRinging
  119.  or cs:[RingTrigger],1
  120. NotRinging:
  121.  dec cs:[RingTimer]
  122.  jnz NoRingTime
  123.  mov cs:[RingTimer],RingTicks
  124.  mov ax,cs:[RingTrigger]
  125.  or ax,0f000h              ;P Eibl
  126.  cmp ax,0ffffh             ;P Eibl
  127.  je NoCarrier
  128.  shl ax,1
  129.  mov cs:[RingTrigger],ax
  130. ;  2.  Reboots system if carrier lost during critical period
  131. ;    This allows Doors to be used safely
  132. NoRingTime:
  133.  cmp cs:[Flag],'I' and 0fh
  134.  jb NoMonitor
  135.  je TimeCheck
  136.  in al,dx
  137.  and al,CarrierDetect
  138.  jz NoCarrier
  139. NoMonitor:
  140.  pop ds
  141.  pop dx
  142.  pop ax
  143.  jmp cs:[TimerInt]
  144. NoCarrier:
  145.  jmp cs:[ColdBoot]
  146. ;  1.  Reboots system if no carrier in specified period of time
  147. ;    This catches RBBS or system failures
  148. TimeCheck:
  149.  test al,CarrierDetect
  150.  jnz ResetTime
  151.  dec cs:[Seconds]
  152.  jnz NoMonitor
  153.  mov cs:[Seconds],tpm
  154.  dec cs:[Minutes]
  155.  jz NoCarrier
  156.  jmp short NoMonitor
  157. ResetTime:
  158.  mov ax,cs:[MinReset]
  159.  mov cs:[Minutes],ax
  160.  jmp short NoMonitor
  161. ;
  162. ;
  163. ;
  164. ;
  165.  assume ds:@code,es:@code,ss:@code
  166. init:
  167.  mov dx,offset SignOnMessage
  168.  mov ax,0900h
  169.  int 21h     ;print load message
  170.  mov ax,[word ptr Ident2]
  171.  xor [word ptr Ident],ax
  172.  mov ax,[word ptr Ident2+2]
  173.  xor [word ptr Ident+2],ax
  174.  xor dx,dx
  175.  mov es,dx
  176.  mov si,offset Ident
  177.  mov cx,cs
  178.  mov ax,[si]
  179. findloop:
  180.  cmp ax,es:[si]
  181.  jz found
  182. NotQuite:
  183.  inc dx
  184.  mov es,dx
  185.  loop findloop
  186. LoadWatchCat:
  187.  xor bx,bx
  188.  mov es,bx
  189.  mov bl,ds:[82h]
  190.  cmp bl,'0'
  191.  jle NoCom
  192.  cmp bl,'4'
  193.  jle ComSpec
  194. NoCom:
  195.  mov bl,'1'
  196. ComSpec:
  197.  mov [ComPortNumber],bl
  198.  add bx,bx
  199.  mov ax,es:[bx+400h-31h-31h]
  200.  mov [ComPort],ax
  201.  cmp byte ptr ds:[83h],'C'
  202.  jnz NotColor
  203.  mov [ScreenSegment],0b800h
  204.  mov [ScreenSegNum],'8'
  205. NotColor:
  206.  mov ax,3508h
  207.  int 21h     ;get timer interrupt
  208.  mov [word ptr TimerInt],bx
  209.  mov [word ptr TimerInt+2],es
  210.  mov dx,offset Timer
  211.  mov ax,2508h
  212.  int 21h     ;set timer interrupt
  213.  mov dx,offset message1
  214.  mov ax,0900h
  215.  int 21h     ;print load message
  216.  mov dx,(init-first+15)/16
  217.  mov ax,3101h
  218.  int 21h      ;TSR
  219. Found:
  220.  mov bx,[si+2]
  221.  cmp bx,es:[si+2]
  222.  jnz NotQuite
  223.  mov ax,es
  224.  mov bx,10h
  225.  mov di,offset message2x
  226.  mov cx,4
  227. loc:
  228.  mul bx
  229.  cmp dl,9
  230.  jbe locx
  231.  add dl,7
  232. locx:
  233.  add dl,'0'
  234.  mov [di],dl
  235.  inc di
  236.  loop loc
  237.  mov ax,es:[MinReset]
  238.  mov es:[Minutes],ax
  239.  mov al,ds:[83h]
  240.  and al,0fh
  241.  mov es:[Flag],al
  242.  mov dx,offset message2tim
  243.  cmp al,'I' and 0fh
  244.  jz done
  245.  mov dx,offset message2off
  246.  jb done
  247.  mov dx,offset message2on
  248. done:
  249.  push dx
  250.  mov dx,offset message2
  251.  mov ax,0900h
  252.  int 21h
  253.  pop dx
  254.  mov ax,0900h
  255.  int 21h
  256.  mov ax,4c00h
  257.  int 21h
  258. message1 db 0ah,0dh,'Watchcat Loaded, set to COM'
  259. ComPortNumber db '1 and Screen B'
  260. ScreenSegNum db '000',0ah,0dh,'$'
  261. message2 db 0ah,0dh,'Watchcat found at '
  262. message2x db '0000 and set to $'
  263. message2on db 'ON',0ah,0dh,'$'
  264. message2off db 'OFF',0ah,0dh,'$'
  265. message2tim db 'TIMER',0ah,0dh,'$'
  266. SignOnMessage db 0dh,0ah,'WATCHCAT, copyright 1989 Joseph R. Ahlgren'
  267.  db '   RBBS 703-241-7980',0dh,0ah
  268.  db ' WATCHCAT may be freely distributed provided this message is not modified',0dh,0ah
  269.  db ' Load with WATCHCAT ps, where p is the port number (1,2,3,4)',0dh,0ah
  270.  db '  and s is the screen type (Color or Mono), e.g., WATCHCAT 2C',0dh,0ah
  271.  db '  specifies COM2 and Color Screen',0ah,0dh
  272.  db ' Subsequent calls are WATCHCAT ON, WATCHCAT OFF, and WATCHCAT TIMER',0dh,0ah
  273.  db '  OFF disables all functions',0dh,0ah
  274.  db '  ON reboots if carrier lost',0dh,0ah
  275.  db '  TIMER reboots if 20 rings without answering phone, if no carrier',0dh,0ah
  276.  db '   in 8 hours, or if "Hit any key to return to system" appears on screen',0dh,0ah
  277.  db '   Also, pressing both Left and Right Shift keys simultaneously will',0dh,0ah
  278.  db '   drop the line, logging off the current user.',0dh,0ah
  279.  db '$'
  280.  Lowmem segment at 0000h
  281.  org 417h
  282. ShiftStatus db ?
  283. Lowmem ends
  284.  end start
  285.